package com.antcom.antread.antreadmodules.antreadsystem.log.controller;

import com.antcom.antread.antreadmodules.antreadsystem.log.service.ILogService;
import com.antcom.antread.api.domain.OperationLog;
import com.antcom.antread.common.core.baseRest.controller.BaseRestController;
import com.antcom.antread.common.core.baseRest.domain.GeneralSet;
import com.antcom.antread.common.core.baseRest.domain.PageDevice;
import org.springframework.web.bind.annotation.*;

import javax.inject.Inject;

/**
 * controller: 日志
 *
 * @Author 中国蚂蚁技术有限公司
 * @create 2020/12/25 22:14
 */
@RestController
@RequestMapping("/logger/aspect")
public class LogController extends BaseRestController {

    @Inject
    private ILogService iLogService;

    @PostMapping("/recordLogger")
    public GeneralSet recordLogger(@RequestBody OperationLog operationLog) {
        iLogService.save(operationLog);
        return success();
    }

    @PostMapping("/findOne/{operId}")
    public GeneralSet findOne(@PathVariable String operId){
        OperationLog operationLog = iLogService.findOne(operId);
        return success(operationLog);
    }

    @PostMapping("/deleteById/{operId}")
    public GeneralSet deleteById(@PathVariable String operId){
        iLogService.deleteById(operId);
        return success();
    }

    @PostMapping("/getPage")
    public GeneralSet getPage(){
        String param = getParam(request);
        PageDevice pageDevice = iLogService.findAllPage(param);
        return success(pageDevice);
    }

}
